using Headsight.BPMN2WF.Testing.TestObjCtors;
using Headsight.BPMN2WF.Transformation;
using Headsight.BPMN2WF.Transformation.Transformers.NoGoodName;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;

namespace Headsight.BPMN2WF.WF.Simplification
{
    [TestClass]
    public class BPMN2WFTransformationResultsCollectorTest : BPMN2WFTransformationDelegateBaseImplTestFixture<BPMN2WFTransformationResultsCollector>
    {
        protected override BPMN2WFTransformationResultsCollector CreateSut(IBPMN2WFTransformation @delegate)
        {
            return new BPMN2WFTransformationResultsCollector(@delegate);
        }

        [TestMethod]
        public void Transform_return_delegates_result()
        {
            var expected = new BPMNTransformationResultCtor().Create();
            _delegate.Expect(x => x.Transform(_ctx, _bpmnFlowNode)).Return(expected);

            Assert.AreSame(expected, _sut.Transform(_ctx, _bpmnFlowNode));
        }

        [TestMethod]
        public void Transform_adds_result_to_BPMN2WFTransformationContexts_BPMNTransformationResults()
        {
            var expected = new BPMNTransformationResultCtor().Create();
            _delegate.Expect(x => x.Transform(_ctx, _bpmnFlowNode)).Return(expected);

            _sut.Transform(_ctx, _bpmnFlowNode);

            Assert.AreSame(expected, _ctx.BPMNTransformationResults[_bpmnFlowNode]);
        }

        [TestMethod]
        public void Transform_inco_bpmnFlowNode_has_already_been_transformed_as_in_case_of_a_converging_gateway()
        {
            var expected = new BPMNTransformationResultCtor().Create();
            _delegate.Expect(x => x.Transform(_ctx, _bpmnFlowNode)).Return(expected);

            var bpmnTransformationResult = new BPMNTransformationResultCtor().Create();
            _ctx.BPMNTransformationResults[_bpmnFlowNode] = bpmnTransformationResult;

            _sut.Transform(_ctx, _bpmnFlowNode);

            Assert.AreSame(bpmnTransformationResult, _ctx.BPMNTransformationResults[_bpmnFlowNode]);
        }
    }
}